package cn.kshost.zqyg.manager.service.impl;

import cn.kshost.zqyg.manager.mapper.ProductSpecMapper;
import cn.kshost.zqyg.manager.service.ProductSpecService;
import cn.kshost.zqyg.model.entity.product.ProductSpec;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductSpecServiceImpl implements ProductSpecService {
    @Autowired
    ProductSpecMapper productSpecMapper;

    @Override
    public PageInfo<ProductSpec> geyByPage(int pageNum, int pageSize) {

       PageHelper.startPage(pageNum, pageSize);
       List<ProductSpec> productSpecs =  productSpecMapper.selectAll();

       return new  PageInfo<>(productSpecs);
    }

    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.insert(productSpec);
    }

    @Override
    public void updateById(ProductSpec productSpec) {
        productSpecMapper.updateById(productSpec);
    }

    @Override
    public void removeById(Long id) {
        productSpecMapper.deleteById(id);
    }

    @Override
    public List<ProductSpec> findAll() {
        List<ProductSpec> productSpecs = productSpecMapper.selectAll();
        return productSpecs;
    }
}
